<?php

/**
 * apNodeFieldForm
 * Adds form element to the node form for the extra friendlyname field
 *
 * @package    authpuppy
 * @subpackage plugin
 * @author     Geneviève Bastien <gbastien@versatic.net>
 * @version    $Id: pre-alpha$
 */
class apNodeFieldForm extends BaseFormDoctrine
{
  /**
   * @see sfForm
   */
  public function setup()
  {
    parent::setup();
    
    $this->widgetSchema['friendlyname'] = new sfWidgetFormInput();
    $this->widgetSchema->setHelp("friendlyname", 'A friendly name with no special characters that can be used to form external urls if the %friendlyname% path option is set in the external url redirects');
    $this->validatorSchema['friendlyname'] = new sfValidatorRegex(array('pattern' => "/^[A-Za-z0-9\-]+$/", 'required' => false));
    
    $this->widgetSchema["portal_page"] = new sfWidgetFormInputText();
    $this->widgetSchema->setHelp("portal_page", 'The url of the portal page if it cannot be built by the ExternalCMS plugin\'s configuration options');
    
    $this->validatorSchema['portal_page'] = new sfValidatorRegex(array('pattern' => "/^http[s]?:\/\/.*$/", 'required'=>false), 
      array('invalid' => "Url must be of the form 'http://site' or 'https://site'"));
      
    $this->widgetSchema["login_page"] = new sfWidgetFormInputText();
    $this->widgetSchema->setHelp("login_page", 'The url of the login page if it cannot be built by the ExternalCMS plugin\'s configuration options.  You can use parameters to define this url: possible values: %nodeid%, %gwid%, %nodename%, %friendlyname%, %originurl%, %identitytype%, %identityname%, %getparameters%.<br>Note it has to be within the firewall\'s walled garden so the user can access it without being logged in.');
    
    $this->validatorSchema['login_page'] = new sfValidatorRegex(array('pattern' => "/^http[s]?:\/\/.*$/", 'required'=>false), 
      array('invalid' => "Url must be of the form 'http://site' or 'https://site'"));
    
    
    
  }
  
  public function getModelName() {
      return 'Node'; 
  }

}